package ucd.csi.comp30220.fall2011.oteop.flight;

import java.io.Serializable;
import java.util.Date;

import ucd.csi.comp30220.fall2011.oteop.flughafen.AirportInfo;
import ucd.csi.comp30220.fall2011.oteop.navigation.Position;

/**
 * 
 * @author David Harrison
 *
 */
public final class FlightInfo implements Serializable {
    
    private static final long serialVersionUID = -6474538151310968171L;
    
    private String airline;
    private String number;
    private String callsign;
    private PlaneInfo planeInfo;
    private Date departureDateTime;
    private AirportInfo departureAirportInfo;
    private AirportInfo destinationAirportInfo;
    
    public FlightInfo(
            String airline,
            String number,
            String callsign,
            PlaneInfo planeInfo,
            Date departureDateTime,
            AirportInfo departureAirportInfo,
            AirportInfo destinationAirportInfo) {
        this.airline = airline;
        this.number = number;
        this.callsign = callsign;
        this.planeInfo = planeInfo;
        this.departureDateTime = 
            departureDateTime == null ? null : new Date(departureDateTime.getTime());
        this.departureAirportInfo = departureAirportInfo;
        this.destinationAirportInfo = destinationAirportInfo;
    }
    
    /** @return 'Aer Lingus' or similar */
    public String getAirline() {
        return airline;
    }
    
    /** @return 'EI139' for Aer Lingus from Dublin to Boston */
    public String getNumber() {
        return number;
    }
    
    /** @return 'Shamrock one tree niner heavy' for an Aer Lingus wide-body jet */
    public String getCallsign() {
        return callsign;
    }
    
    /** @return our aluminuum tube with wings, engines and stuff */
    public PlaneInfo getPlaneInfo() {
        return planeInfo;
    }

    /** @return time we would like to set off */
    public Date getDepartureDateTime() {
        return departureDateTime == null ? null : new Date(departureDateTime.getTime());
    }
    
    /** @return where we set off from, or will set off from */
    public Position getDeparturePoint() {
        return departureAirportInfo.getPosition();
    }
    
    /** @return where we (hope) to end up */
    public Position getDestination() {
        return destinationAirportInfo.getPosition();
    }
    
    /** @return the departure airport info */
    public AirportInfo getDepartureAirportInfo() {
        return departureAirportInfo;
    }
    
    /** @return the destination airport info */
    public AirportInfo getDestinationAirportInfo() {
        return destinationAirportInfo;
    }

    public void setDestinationAirportInfo(AirportInfo destinationAirportInfo) {
        this.destinationAirportInfo = destinationAirportInfo;
    }

    public void setDepartureAirportInfo(AirportInfo departureAirportInfo) {
        this.departureAirportInfo = departureAirportInfo;
    }

    @Override
    public String toString() {
        return "FlightInfo [airline=" + airline + ", number=" + number
                + ", callsign=" + callsign + ", planeInfo=" + planeInfo
                + ", departureDateTime=" + departureDateTime
                + ", departureAirportInfo=" + departureAirportInfo
                + ", destinationAirportInfo=" + destinationAirportInfo + "]";
    }
}
